ig.module( 
	'game.gameTypes.gameMazeFood' 
)
.requires(
	'impact.game',
	'game.gameTypes.gameBase',
	'game.entities.base.pickObject'	
)
.defines(function()
{
    GameMazeFood = GameBase.extend(
    {
	font: new ig.Font( 'media/04b03.font.png' ),
	
        init: function()
        {
	    this.parent();
	    ig.global.numberOfPicks = 0
	    ig.global.failed = false;
	    ig.global.validPicks = 0;
	    ig.global.typeToPick = 'blueGhost';
        },
        
	postInit: function()
	{
	    var validPicks = ig.game.getEntitiesByType(EntityPickObject);
	    
	    for (var i = 0; i < validPicks.length; ++i)
	    {
		if (validPicks[i].pickType == ig.global.typeToPick)
		{
		    ig.global.validPicks++;
		}
	    }	    			
	},
	
        update: function()
        {
	    this.parent();
        },
        
	pausedUpdate: function()
	{
	    if (ig.input.state('enter'))
	    {					    
		this.game.loadLevelDeferred(LevelMazeCatch);
		ig.global.failed = false;
		ig.global.paused = false;
		ig.global.numberOfPicks = 0;
	    }
	},
	
        draw: function()
        {
	    this.parent();
	    this.font.draw( 'Pontuacao: ' + ig.global.numberOfPicks, 30, 450, ig.Font.ALIGN.CENTER );
	    this.font.draw( 'Numero de ovelhas azuis: ' + ig.global.validPicks, 30, 460, ig.Font.ALIGN.CENTER );
	    this.font.draw( 'Touches: ' + ig.global.touched, 30, 470, ig.Font.ALIGN.CENTER );
	    
	    if (ig.global.numberOfPicks == ig.global.validPicks)
	    {
		this.font.draw( 'Parabens, voce conseguiu pegar todas as ovelhas?', 180, 80, ig.Font.ALIGN.CENTER );
		this.font.draw( 'Pressione enter.', 180, 90, ig.Font.ALIGN.CENTER );
		ig.global.paused = true;
	    }
	    else if (ig.global.failed == true)
	    {
		this.font.draw( 'Ops... esta ovelha nao era azul. Vamos tentar novamente?', 180, 80, ig.Font.ALIGN.CENTER );
		this.font.draw( 'Pressione enter.', 180, 90, ig.Font.ALIGN.CENTER );
		ig.global.paused = true;				
	    }
	    else
	    {
		this.font.draw( 'Voce deve pegar as ovelhas azuis: ', 80, 80, ig.Font.ALIGN.CENTER );
	    }
        }       
    });
});